package com.avcdata.aoscustommade.presenter;

import com.avcdata.aoscustommade.bean.BaseResponseBean;
import com.avcdata.aoscustommade.bean.DateSelectCategoryBean;
import com.avcdata.aoscustommade.bean.TopBrandAndSelfBrandBean;
import com.avcdata.aoscustommade.main.BaseCallBack;
import com.avcdata.aoscustommade.model.CityDatailActivityModel;
import com.avcdata.aoscustommade.model.CitySelectaActivityModel;
import com.avcdata.aoscustommade.view.CitySelectaActivityView;

import org.json.JSONObject;

/**
 * 城市选择信息页的presenter
 * Created by zyh on 17/6/8.
 */

public class CitySelectaActivityPresenter {
    private final CitySelectaActivityView citySelectaActivityView;
    private final CitySelectaActivityModel citySelectaActivityModel;
    private final CityDatailActivityModel cityDatailActivityModel;

    public CitySelectaActivityPresenter(CitySelectaActivityView citySelectaActivityView, CitySelectaActivityModel citySelectaActivityModel, CityDatailActivityModel cityDatailActivityModel) {
        this.citySelectaActivityView = citySelectaActivityView;
        this.citySelectaActivityModel = citySelectaActivityModel;
        this.cityDatailActivityModel = cityDatailActivityModel;
    }

    /**
     * 获取产品类型日期等
     *
     * @param type
     * @param lastWeekCount
     */
    public void loadSelectCategory(String type, int lastWeekCount) {
        cityDatailActivityModel.loadSelectCategory(type, lastWeekCount, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                citySelectaActivityView.loadSelectCategorySuccess((DateSelectCategoryBean) object);
            }

            @Override
            public void onFailure() {
                citySelectaActivityView.loadSelectCategoryFailure();
            }

            @Override
            public void onFailure(Throwable throwable) {
                citySelectaActivityView.loadSelectCategoryFailure(throwable);
            }
        });
    }

    /**
     * 获取城市品牌排行
     *
     * @param category
     * @param brand
     * @param topBrandCount
     * @param lastWeek
     * @param lastWeekCount
     * @param bigRegion
     * @param officeName
     * @param cityName
     */
    public void loadCityBrandList(String category, String brand, int topBrandCount, String lastWeek, int lastWeekCount, String bigRegion, String officeName, String cityName) {
        citySelectaActivityModel.loadCityBrandList(category, brand, topBrandCount, lastWeek, lastWeekCount, bigRegion, officeName, cityName, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                citySelectaActivityView.loadCityBrandListSuccess((TopBrandAndSelfBrandBean) object);
            }

            @Override
            public void onFailure() {
                citySelectaActivityView.loadCityBrandListFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                citySelectaActivityView.loadCityBrandListFailure(throwable);
            }
        });
    }

    /**
     * 城市行业销售额同环比
     * @param topBrandCount
     * @param lastWeek
     * @param lastWeekCount
     * @param brand
     * @param bigRegion
     * @param officeName
     * @param cityName
     */
    public void loadCityIndustrySales(int topBrandCount, String lastWeek, int lastWeekCount, String brand, String bigRegion, String officeName, String cityName) {
        citySelectaActivityModel.loadCityIndustrySales(topBrandCount, lastWeek, lastWeekCount, brand, bigRegion, officeName, cityName, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                citySelectaActivityView.loadCityIndustrySalesSuccess((JSONObject)object);
            }

            @Override
            public void onFailure() {
                citySelectaActivityView.loadCityIndustrySalesFailure();
            }

            @Override
            public void onFailure(Throwable throwable) {
                citySelectaActivityView.loadCityIndustrySalesFailure(throwable);
            }
        });
    }

    /**
     * 城市趋势图
     * @param category
     * @param brand
     * @param topBrandCound
     * @param lastWeek
     * @param lastWeekCount
     * @param bigRegion
     * @param officeName
     * @param cityName
     */
    public void loadCityTrend(String category, String brand, int topBrandCound, String lastWeek, int lastWeekCount, String bigRegion, String officeName, String cityName) {
        citySelectaActivityModel.loadCityTrend(category, brand, topBrandCound, lastWeek, lastWeekCount, bigRegion, officeName, cityName, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                citySelectaActivityView.loadCityTrendSuccess((JSONObject)object);
            }

            @Override
            public void onFailure() {
                citySelectaActivityView.loadCityTrendFailure();
            }

            @Override
            public void onFailure(Throwable throwable) {
                citySelectaActivityView.loadCityTrendFailure(throwable);
            }
        });
    }

    /**
     * 城市行业占饼图
     * @param topBrandCount
     * @param lastWeek
     * @param lastWeekCount
     * @param brand
     * @param bigRegion
     * @param officeName
     * @param cityName
     */
    public void loadPiePicture(int topBrandCount, String lastWeek, int lastWeekCount, String brand, String bigRegion, String officeName, String cityName) {
        citySelectaActivityModel.loadPiePicture(topBrandCount, lastWeek, lastWeekCount, brand, bigRegion, officeName, cityName, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                citySelectaActivityView.loadPiePictureSuccess((JSONObject)object);
            }

            @Override
            public void onFailure() {
                citySelectaActivityView.loadPiePictureFailure();
            }

            @Override
            public void onFailure(Throwable throwable) {
                citySelectaActivityView.loadPiePictureFailure(throwable);
            }
        });
    }
}
